﻿using MediatR;
using MS.Data.API.Write.Applicant.Command.User;
using MS.Data.Domain;
using MS.Data.ErrorCode;
using MS.Data.Infratructrue.Istanbul;

namespace MS.Data.API.Write.Applicant.CommandHandel.User
{
    public class AddUserCommandHandel:IRequestHandler<AddUserCommand,APIResult<int>>
    {
        IBaseRepository<Domain.User> userRep;


        public AddUserCommandHandel(IBaseRepository<Domain.User> userRep)
        {
            this.userRep = userRep;

        }

        public async Task<APIResult<int>> Handle(AddUserCommand request, CancellationToken cancellationToken)
        {
            APIResult<int> result = new APIResult<int>();
            result.code=APIEnum.添加成功;
            result.mes = APIEnum.添加成功.ToString();

            request.user.CreaTime = DateTime.Now;

            await userRep.Add(request.user);


            return await Task.FromResult(result);

        }
    }
}
